#!/usr/bin/env python
# -*- coding: utf-8 -*-
import platform
from flask_script import Command, Option
from spider.data.xhs.spider_comments import start_replay


class SpiderXhsComments(Command):
    """
        # 机动脚本
        python manager.py spider_xhs_comments
    """

    def get_options(self):
        return [
            Option('-u', '--url', dest='url'),
            Option('-k', '--keywords', dest='keywords'),
            Option('-c', '--content', dest='content'),
            Option('-v', '--version', dest='version'),
            Option('-p', '--port', dest='port')
        ]


    def run(self, url, keywords, content, version, port):
        print(platform.system())
        if not url:
            print('请输入url参数 python manager.py spider_xhs_comments -u https://www.baidu.com')
        elif not keywords:
            print('请输入keywords参数')
        elif not content:
            print('请输入content参数')
        elif not version:
            print('请输入version参数')
        elif not port:
            print('请输入port参数')
        else:
            start_replay(url, keywords, content, version, port)

